package com.kws.merchant.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kws.merchant.domain.MerchantScoreEntity;
import com.kws.merchant.domain.vo.MerchantDetailVo;
import com.kws.merchant.domain.vo.ShopsScoreVo;
import com.kws.merchant.domain.vo.UserServeVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author : zhangbenting
 * @date : 2024/11/20 11:05
 * @Version: 1.0
 */
public interface MerchantScoreMapper extends BaseMapper<MerchantScoreEntity> {


    @Select("SELECT " +
            " a.id AS merchant_id, " +
            " a.business_license_url AS business_license, " +
            " a.company_name AS merchant_name, " +
            " a.logo AS shop_img, " +
            " a.company_address AS address, " +
            " a.create_time AS open_time, " +
            " a.merchant_remark AS introduction, " +
            " b.shop_score, " +
            " b.remark_score, " +
            " b.delivery_score, " +
            " b.after_sale_score, " +
            " b.consult_score  " +
            "FROM " +
            " `tb_merchant` AS a " +
            " LEFT JOIN tb_merchant_score AS b ON b.merchant_id = a.id  " +
            "WHERE " +
            " a.id = ${merchantId}")
    MerchantDetailVo getMerchantDetail(@Param("merchantId") Long merchantId);

    @Select("SELECT " +
            " a.shop_score, " +
            " a.remark_score, " +
            " a.delivery_score, " +
            " a.after_sale_score, " +
            " a.consult_score, " +
            " b.company_name as shop_name, " +
            " b.logo as shop_img " +
            "FROM " +
            " `tb_merchant` AS b " +
            " LEFT JOIN `tb_merchant_score` AS a ON a.merchant_id = b.id  " +
            "WHERE " +
            " b.id = ${merchantId} ")
    ShopsScoreVo getShopsScore(@Param("merchantId") Long merchantId);

    @Select("SELECT " +
            " a.id AS serve_id, " +
            " a.`name`, " +
            " a.img, " +
            " a.remark, " +
            " b.company_name AS shops_name, " +
            " b.id AS shops_id  " +
            "FROM " +
            " tb_serve AS a " +
            " LEFT JOIN tb_merchant AS b ON a.merchant_id = b.id  " +
            "WHERE " +
            " a.id = ${serveId} ")
    UserServeVo getServeInfo(@Param("serveId") Long serveId);
}
